package com.dbappsecurity.jsbridge.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by arirus on 2017/9/19.
 */

public class JsAppInfoUtils {
  public static String getAppVersionName(Context context) {
    try {
      PackageManager manager = context.getPackageManager();
      PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
      String version = info.versionName;
      return version;
    } catch (Exception e) {
      e.printStackTrace();
      return "UNKNOWN";
    }
  }

  public static String getAppVersionCode(Context context) {
    try {
      PackageManager manager = context.getPackageManager();
      PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
      String version = String.valueOf(info.versionCode);
      return version;
    } catch (Exception e) {
      e.printStackTrace();
      return "UNKNOWN";
    }
  }
}
